package com.youyun56.gps.android.common;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.URLSpan;
import android.util.Log;

public class TelSpanUtils {
    private final static String tag = TelSpanUtils.class.getName();
    private final static Pattern telPattern = Pattern.compile("(\\d|-){6,}");

    public static void telSpan(SpannableString ss, String str, int start) {
        Matcher matcher = telPattern.matcher(str);
        while (matcher.find()) {
            Log.i(tag, matcher.group());
            if (matcher.start() >= start) {
                ss.setSpan(new URLSpan(new StringBuilder("tel:").append(matcher.group()).toString()), matcher.start(),
                        matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
    }

}
